﻿using NHibernate;
using OpenWaves.ActivityFeed.NHibernate;
using OpenWaves.ActivityFeed.UnitTests;

namespace OpenWaves.ActivityFeed.UnitTests_NHibernate
{
    class NHibernateActivityFeedTestSession : IActivityFeedTestSession
    {
        private readonly ISession session;
        private readonly ITransaction transaction;

        public NHibernateActivityFeedTestSession(ISession session, ITransaction transaction)
        {
            this.session = session;
            this.transaction = transaction;
        }

        public void Dispose()
        {
            this.transaction.Dispose();
            this.session.Dispose();
        }

        public IActivityFeedService CreateActivityFeedService()
        {
            return new NHibernateActivityFeedService(this.session);
        }

        public void SaveChanges()
        {
            this.transaction.Commit();
        }
    }
}